import { resolve } from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

/**
 * Vite 配置文件
 * https://vitejs.dev/config/
 */
export default defineConfig({
  envDir: resolve("env"),
  envPrefix: "DREAMER_",
  plugins: [vue()],
  resolve: {
    alias: {
      "@": resolve(__dirname, "./src"),
    },
  },
  server: {
    hmr: { overlay: false },
    cors: true,
    host: "0.0.0.0",
    //代理跨域配置
    proxy: {
      "/api": {
        target: "https://api.virapi.com/iteachyou/dreamer_admin", // 后台接口
        changeOrigin: true,
        secure: false, // 如果是https接口，需要配置这个参数
        ws: true, //websocket支持
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  }
})
